package com.sup.model;

import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.sup.common.BaseModel;
import com.sup.utils.StringUtils;

@Entity
@Table(name="production_type")
@Cacheable
@Cache(usage=CacheConcurrencyStrategy.TRANSACTIONAL,include="non-lazy")
public class ProductionType extends BaseModel{
	
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Long id;
	
	@Column(name="production_type_number")
	private Long productionTypeNumber;
	
	@Column(name="production_type")
	private String productionType;
	
	private String description;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getProductionTypeNumber() {
		return productionTypeNumber;
	}

	public void setProductionTypeNumber(Long productionTypeNumber) {
		this.productionTypeNumber = productionTypeNumber;
	}

	public String getProductionType() {
		return productionType;
	}

	public void setProductionType(String productionType) {
		this.productionType = productionType;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	public boolean compareTo(ProductionType type){
		if(this.productionTypeNumber!=type.getProductionTypeNumber()){
			return true;
		}
		if(!this.productionType.equals(type.getProductionType())){
			return true;
		}
		if(StringUtils.isEmpty(description)){
			if(!StringUtils.isEmpty(type.getDescription())){
				return true;
			}
				
		}
		else{
			if(StringUtils.isEmpty(type.getDescription())){
				return true;
			}
			else {
				if(!description.equals(type.getDescription())){
					return true;
				}
					
			}
		}
		return false;
	}

}
